package cn.mxz.xmu.restful.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.mxz.xmu.restful.service.LibraryService;
import cn.mxz.xmu.restful.util.Encrypt;

/**
 * 与图书馆相关的功能的控制器
 * 
 * @author kangbin <kangbin@mouge.wang>
 * @since 2015-03-10
 */
@Scope("prototype")
@Controller
@RequestMapping("library")
public class LibraryControll
{
	private static final Logger LOG = LoggerFactory.getLogger(LibraryControll.class);

	@Autowired
	private LibraryService service;

	@ResponseBody
	@RequestMapping(value = "/param/{method}/{value}", method = RequestMethod.GET)
	public String param(@PathVariable String method, @PathVariable String value)
	{
		String result = service.param(Encrypt.urlDecode(Encrypt.hex2Dec(method)), Encrypt.urlDecode(Encrypt.hex2Dec(value)));
		LOG.info("/param/" + Encrypt.urlDecode(Encrypt.hex2Dec(method)) + "/" + Encrypt.urlDecode(Encrypt.hex2Dec(value)) + ":" + result);
		return result;
	}

}
